<template>
  <div>
    <van-popup 
      v-model="show" 
      position="right" 
      :style="{ width: '472px',height: '100%' }"  @click-overlay="showClick"
      :close-on-click-overlay="false">
      <div class="content_box">
        <div class="icon_screen">
          <img src="../../../assets/img/navbar/ic_header_preparation.png" alt="" @click="showClick">
        </div>
        <h3>充值时间</h3>
        <ul class="equipment_box">
          <li 
            v-for="(item, index) in equipmentList" 
            :key="index" 
            class="equipment_list" 
            @click="choiceTime(index)"
            :class="[currentIndex === index ? 'equipment_active': '']">
            {{item}}
          </li>
        </ul>
        <div class="equipment_box">
          <van-field input-align="center" class="equipment_list equipment_input" placeholder="起始时间" v-model="begintime" :readonly="true" @click="startClick"></van-field>
          <van-field input-align="center" class="equipment_list equipment_input" placeholder="结束时间" v-model="endtime" :readonly="true" @click="endClick"></van-field>
        </div>
        <p class="tips">*最多可查询近期三个月数据</p>
        <div class="btn">
          <van-button class="reset_btn" @click="resetClick">重置</van-button>
          <van-button class="confirm_btn" @click="sureSearch">确定</van-button>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script>
  export default {
    props: {
      show: {
        type: Boolean,
        default: false,
      },
      begintime: {
        type: String,
        default: '',
      },
      endtime: {
        type: String,
        default: '',
      },
    },
    data() {
      return {
        equipmentList: ['今日', '昨日', '本周', '本月', '上月'],
        currentIndex: null,
      }
    },
    methods: {
      showClick() {
        this.$emit('show-click')
      },
      resetClick() {
        this.$emit('reset-date')
        this.currentIndex = null
      },
      startClick() {
        this.$emit('start-click')
        this.currentIndex = null

      },
      endClick() {
        this.$emit('end-click')
        this.currentIndex = null
      },
      choiceTime(index) {
        this.currentIndex = index
        this.$emit('choice-time',index)
      },
      sureSearch() {
        this.$emit('sure-search')
      }
    },
  }
</script>

<style scoped>
.content_box {
  height: 100%;
  background: #fff;
  padding: 0 54px;
}

.icon_screen {
  width: 44px;
  height: 44px;
  padding: 40px 0 40px 320px;
}

.icon_screen img {
  width: 100%;
  height: 100%;
}

.content_box h3 {
  font-size: 28px;
  color: #333;
}

.equipment_box {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 20px 0 0 0;
  flex-wrap: wrap;
}

.equipment_list {
  width: 167px;
  height: 64px;
  border: 1px solid #e7e7e7;
  text-align: center;
  line-height: 64px;
  font-size: 24px;
  color: #242424;
  border-radius: 10px;
  margin-bottom: 20px;
}

.equipment_active {
  border: 0;
  background: #2f41eb;
  color: #fff;
}

.equipment_input {
  padding: 0;
}

.gametype_box {
  padding: 20px 0 60px 0;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.gametype_list {
  box-sizing: border-box;
  margin-bottom: 18px;
  width: 115px;
  height: 60px;
  border: 1px solid #e7e7e7;
  text-align: center;
  line-height: 60px;
  font-size: 24px;
  color: #242424;
  border-radius: 10px;
}

.gametype_active {
  border: 0;
  background: #2f41eb;
  color: #fff;
}

.btn {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 88px;
}

.reset_btn,
.confirm_btn {
  width: 50%;
  height: 100%;
  font-size: 28px;
  font-weight: 500;
  border: 0;
  box-sizing: border-box;
  border-radius: 0;
}

.confirm_btn {
  background: #2f41eb;
  color: #fff;
}

.reset_btn {
  border-top: 1px solid #999;
}

.tips {
  font-size: 24px;
  color: #999;
}
</style>